package com.example.planetandzombiedemo.entity;

import android.graphics.Canvas;
import android.graphics.Paint;

import com.example.planetandzombiedemo.global.Config;
import com.example.planetandzombiedemo.model.BaseModel;

public class Zombie extends BaseModel {
    //僵尸所在跑道
    private int raceWay;
    //动画帧
    private int frameIndex = 0;
    //移动速度
    private float speedX = 3;

    public Zombie(int locationX, int locationY, int raceWay) {
        this.locationX = locationX;
        this.locationY = locationY;
        this.isAlife = true;
        this.raceWay = raceWay;
    }

    @Override
    public void drawSelf(Canvas canvas, Paint paint) {
//边界：从右往左（消失）
        if (locationX < 0) {

        }
        if (isAlife) {
            canvas.drawBitmap(Config.zombieFrames[frameIndex], locationX, locationY, paint);
            frameIndex = (++frameIndex) % 7;
            locationX -= speedX;
        }
    }

    @Override
    public int getModelWidth() {
        return Config.zombieFrames[0].getWidth();
    }
}
